<template>
  <div>
     <ArticleList :articleInfos="articleData" :curPageNo="1" :curTag="tag" :maxItems="maxItems"/>
  </div>
</template>

<script>
import ArticleList from '~/components/ArticleList.vue';
export default {
  asyncData ({ app, params, query, env, error }) {
    let apiurl = `${env.apiServer.baseUrl}/articles?offset=0&limit=${env.page.lineNumber}`;
    return app.$axios.get(apiurl)
      .then((res) => {
        
        if (res.data.code === 0){
          return {
            tag: 'all',
            pageNo: 1,
            articleData: res.data.data,
            maxItems: env.page.lineNumber,
          }
        } else {
          error({ statusCode: 404, message: res.data.message })
        }
      })
      .catch(function (e) {
        error({ statusCode: 404, message: e.message })
      });
  },
  components: {
    ArticleList
  },
}
</script>
